package qlsl.androiddesign.view.subview.activityview;

import com.qlsl.androiddesign.kuaiwa.R;

import android.view.View;
import android.widget.BaseAdapter;
import qlsl.androiddesign.activity.subactivity.PostingDetailActivity;
import qlsl.androiddesign.activity.subactivity.PostingReplyActivity;
import qlsl.androiddesign.adapter.subadapter.PostingReplyAdapter;
import qlsl.androiddesign.entity.otherentity.Posting;
import qlsl.androiddesign.entity.otherentity.PostingReply;
import qlsl.androiddesign.http.service.commonservice.MemberService;
import qlsl.androiddesign.view.subview.activityview.peoplecenterbase.PeopleCenterBaseView;

/**
 * 回复我的页<br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
public class PostingReplyView extends PeopleCenterBaseView<PostingReply, PostingReplyActivity> {

	public PostingReplyView(PostingReplyActivity activity) {
		super(activity);
	}

	protected void initView(View view) {
		super.initView(view);
		setTitle("回复我的");
	}

	protected void initData() {
		super.initData();
		MemberService.queryPostingReplytList(1, this, activity);
	}

	protected void initListener() {
		super.initListener();
	}

	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.btn_look:
			doClickLookView(view);
			break;
		}
	}

	private void doClickLookView(View view) {
		int position = refreshView.getRefreshableView().getPositionForView(view);
		PostingReply reply = (PostingReply) refreshView.getAdapter().getItem(position);
		Posting item = new Posting();
		item.setPostingsid(Integer.parseInt(reply.getPostingsid()));
		item.setFirstsection(reply.getFirstsection());
		item.setSecondsection(reply.getSecondsection());
		item.setPostingsname(reply.getTitle());
		item.setPostingscontent(reply.getPostingscontent());
		item.setViews(Integer.parseInt(reply.getViews()));
		item.setComment(Integer.parseInt(reply.getComment()));
		item.setUsername(reply.getUsername());
		item.setHeadphoto(reply.getPhoto());
		item.setTime(reply.getTime());
		startActivity(item, PostingDetailActivity.class);
	}

	public BaseAdapter getAdapter() {
		return new PostingReplyAdapter(activity, list);
	}

}
